//
//  NetManager.h
//  KingSelected
//
//  Created by 杨鹏 on 2023/10/27.
//

#import <Foundation/Foundation.h>
#import "NetworkServer.h"

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, HttpMethod) {
    HttpMethodGET,
    HttpMethodHEAD,
    HttpMethodPOST,
    HttpMethodPUT,
    HttpMethodPATCH,
    HttpMethodDELETE
};

extern BOOL AppHasNetwork;
extern NSString *kHttpErrorReason;

typedef void(^SuccessBlock)(id  _Nullable responseObject);
typedef void(^FailureBlock)(NSError *_Nonnull error);
typedef void(^ProgresBlock)(NSProgress * _Nonnull progress);

@interface NetManager : NSObject

/// 网络请求
+ (void)requestWithUrl:(NSString *)urlString httpMethod:(HttpMethod)httpMethod parameters:(id _Nullable)parameters needEncryption:(BOOL)needEncryption needExtraProcess:(BOOL)needExtraProcess success:(SuccessBlock)success failure:(FailureBlock)failure;

/// 不加密网络请求,返回数据为已处理的数据 dic 或 array ,needExtraProcess 默认NO
+ (void)requestWithUrl:(NSString *)urlString httpMethod:(HttpMethod)httpMethod parameters:(id _Nullable)parameters success:(SuccessBlock)success failure:(FailureBlock)failure;

/// 网络请求,是否加密
+ (void)requestWithUrl:(NSString *)urlString httpMethod:(HttpMethod)httpMethod parameters:(id _Nullable)parameters needEncryption:(BOOL)needEncryption success:(SuccessBlock)success failure:(FailureBlock)failure;

/// post网络请求,是否加密
+ (void)postWithUrl:(NSString *)urlString parameters:(id _Nullable)parameters needEncryption:(BOOL)needEncryption success:(SuccessBlock)success failure:(FailureBlock)failure;

/// post网络请求,是否加密
+ (void)postWithUrl:(NSString *)urlString parameters:(id _Nullable)parameters needEncryption:(BOOL)needEncryption needExtraProcess:(BOOL)needExtraProcess success:(SuccessBlock)success failure:(FailureBlock)failure;

+ (void)getWithUrl:(NSString *)urlString parameters:(id _Nullable)parameters needEncryption:(BOOL)needEncryption needExtraProcess:(BOOL)needExtraProcess success:(SuccessBlock)success failure:(FailureBlock)failure;

/// 上传文件
+ (void)uploadWithURL:(NSString *)urlString parameters:(id _Nullable)parameters fileData:(NSArray *)fileDataArr fileNames:(NSArray *_Nullable)fileNames mimeType:(NSString *_Nullable)mimeType progress:(nonnull ProgresBlock)progress success:(nonnull SuccessBlock)success failure:(nonnull FailureBlock)failure;

@end

NS_ASSUME_NONNULL_END
